package geo.com.geosdkdemo.view.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import geo.com.geosdk.GeoManage;
import geo.com.geosdk.device.devicebean.DeviceInfo;
import geo.com.geosdkdemo.R;

public class DeviceInformationActivity extends AppCompatActivity implements View.OnClickListener {
    private ImageView ivCommonBack;
    private TextView tvCommonTitle;
    private TextView deviceModel;
    private TextView deviceSerial;
    private TextView deviceFwVersion;
    private TextView deviceHwVersion;
    private TextView deviceManufactureData;
    private TextView gpsModel;
    private TextView gpsSerial;
    private TextView gpsFwVersion;
    private TextView gpsHwVersion;
    private TextView gpsLicense;
    private TextView networkIMEI;
    private TextView networkIP;
    private TextView networkSignalLevel;
    private TextView antennaType;
    private TextView antennaR;
    private TextView antennaH;
    private TextView antennaHL1;
    private TextView antennaHL2;


    private DeviceInfo deviceInfo;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_device_information);
        initView();
        initListener();
        initData();
    }


    protected void initView() {
        ivCommonBack=findViewById(R.id.iv_common_back);
        tvCommonTitle=findViewById(R.id.tv_common_title);

        deviceModel=findViewById(R.id.tv_device_model);
        deviceSerial=findViewById(R.id.tv_device_serial);
        deviceHwVersion=findViewById(R.id.tv_device_hardware_version);
        deviceFwVersion=findViewById(R.id.tv_device_firmware_version);
        deviceManufactureData=findViewById(R.id.tv_device_manufacture_data);


        gpsModel=findViewById(R.id.tv_gps_model);
        gpsSerial=findViewById(R.id.tv_gps_serial);
        gpsHwVersion=findViewById(R.id.tv_gps_hardware_version);
        gpsFwVersion=findViewById(R.id.tv_gps_firmware_version);
        gpsLicense=findViewById(R.id.tv_gps_license);

        networkIMEI=findViewById(R.id.tv_network_imei);
        networkIP=findViewById(R.id.tv_network_ip);
        networkSignalLevel=findViewById(R.id.tv_network_signal_level);

        antennaType =findViewById(R.id.tv_other_antenna_type);
        antennaR =findViewById(R.id.tv_other_antenna_r);
        antennaH =findViewById(R.id.tv_other_antenna_h);
        antennaHL1 =findViewById(R.id.tv_other_antenna_hl1);
        antennaHL2 =findViewById(R.id.tv_other_antenna_hl2);

    }


    protected void initListener() {
        ivCommonBack.setOnClickListener(this);
    }


    protected void initData() {
        tvCommonTitle.setText("设备信息");

        deviceInfo = GeoManage.getInstance().getDeviceInfo();

        deviceModel.setText(deviceInfo.mTagDeviceBasicInfo.mDeviceModel);
        deviceSerial.setText(deviceInfo.mTagDeviceBasicInfo.mDeviceSerialNo);
        deviceHwVersion.setText(deviceInfo.mTagDeviceBasicInfo.mDeviceHardwareVersion);
        deviceFwVersion.setText(deviceInfo.mTagDeviceBasicInfo.mDeviceFirmwareVersion);
        deviceManufactureData.setText(deviceInfo.mTagDeviceBasicInfo.mDeviceManufactureData);

        gpsModel.setText(deviceInfo.mTagGpsBasicInfo.mGpsModel);
        gpsSerial.setText(deviceInfo.mTagGpsBasicInfo.mGpsSerialNo);
        gpsHwVersion.setText(deviceInfo.mTagGpsBasicInfo.mGpsHardwareVersion);
        gpsFwVersion.setText(deviceInfo.mTagGpsBasicInfo.mGpsFirmwareVersion);
        gpsLicense.setText(deviceInfo.mTagGpsBasicInfo.mGpsLicense);

        networkIMEI.setText(deviceInfo.mTagNetworkBasicInfo.mNetworkIMEI);
        networkIP.setText(deviceInfo.mTagNetworkBasicInfo.mNetworkIP);
        networkSignalLevel.setText(deviceInfo.mTagNetworkBasicInfo.mNetworkSignalLevel);

        antennaType.setText(deviceInfo.mTagAntennaBasicInfo.mAntennaType);
        antennaR.setText(String.valueOf(deviceInfo.mTagAntennaBasicInfo.mAntennaR));
        antennaH.setText(String.valueOf(deviceInfo.mTagAntennaBasicInfo.mAntennaH));
        antennaHL1.setText(String.valueOf(deviceInfo.mTagAntennaBasicInfo.mAntennaHL1));
        antennaHL2.setText(String.valueOf(deviceInfo.mTagAntennaBasicInfo.mAntennaHL2));
    }

    @Override
    public void onClick(View v) {
        if(v==ivCommonBack){
            finish();
        }
    }

    @Override
    protected void onDestroy() {

        super.onDestroy();
    }
}
